//
//  MoyaViewController.swift
//  testRxSwift
//
//  Created by 火星人 on 2017/7/26.
//  Copyright © 2017年 火星人. All rights reserved.
//

import UIKit
import RxSwift
import RxCocoa
import Moya
import ObjectMapper
import Moya_ObjectMapper

class MoyaViewController: BaseViewController {
    
    let disposeBag = DisposeBag()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        let userProvider = MoyaProvider<User>(stubClosure: MoyaProvider.immediatelyStub)
         
        
        userProvider.request(User.list(0, 10)) { (result) in
            
            
            let status = try! result.dematerialize().mapResult()
            print(status)
        }
    }

}

public extension Response {
    public func mapResult() throws -> Status {
        
        let status = try mapObject(Status.self)
        return status
    }
}
